<?php
/**

 */
define('IN_DOUCO', true);

// 强制在移动端中显示PC版
if (isset($_REQUEST['mobile'])) {
   setcookie('client', 'pc');
   if ($_COOKIE['client'] != 'pc') $_COOKIE['client'] = 'pc';
}

require (dirname(__FILE__) . '/include/init.php');


if ($_REQUEST['lang']) {
    $lang = $_REQUEST['lang'];
}else{
    $lang = 'zh';
}
require (dirname(__FILE__) . '/common.php');

$smarty->assign('dangqun_url', get_dangqun($lang));
$smarty->assign('zhaosheng_url', get_zhaosheng($lang));

if ($_REQUEST['type']) {
    $type = $_REQUEST['type'];
}else{
    $type = '0';
}

if ($_REQUEST['cat_id']){
    $cat_id = $_REQUEST['cat_id'];
}else{
    $cat_id = '1';
}


$ktz_sql = "SELECT id, name FROM ". $dou->table('group') . " where lang='" . $lang . "' order by id ";
$query = $dou->query($ktz_sql);
while ($row = $dou->fetch_array($query)) {
    $ktz_list[] = array (
        "id" => $row['id'],
        "name" => $row['name']
    );  
}



$where = ' WHERE cat_id IN (' . $cat_id . ') and lang=\'' . $lang . '\'';
 // and rgcat_id=\'' . $row['id'] . '\'';

$child_sql  = "SELECT id, name, image, cat_id, rgcat_id, isLeader FROM " . $dou->table('product') . $where . " ORDER BY isLeader DESC, sort ASC, name";
$child_query = $dou->query($child_sql);
while($sub = $dou->fetch_array($child_query))
{    
    $url = 'info.php?type=1&id='.$sub['id'];
    $image = $sub['image'] ? ROOT_URL . $sub['image'] : '';
    $product_list[] = array (
        "id" => $sub['id'],
        "cat_id" => $sub['cat_id'],
        "name" => $sub['name'],
        "image" => $sub['image'],
        "url" => $url, 
        "rgcat_id" => $sub['rgcat_id']
    );
}

$smarty->assign('product_list', $product_list);
$smarty->assign('ktz_list', $ktz_list);
$smarty->assign('lang', $lang);
// $smarty->assign('test', $ktz_sql);

// 赋值给模板-数据
$smarty->display('list_faculty.dwt');

?>
